﻿@model DSAAssignment.Models.ProductDetailModel

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@Html.DisplayFor(model => model.Name)</h2>

<script type="text/javascript">

    $(document).ready(function () {
        show();
    });

    function AddToCart() {
        var id = '@Html.DisplayFor(model => model.ID)';
        $.post("/Product/AddProductsToCart",{productid : id});
    }

    function show() {
        var val = "";
        var id = '@Html.DisplayFor(model => model.ID)';
        var url = "/Product/CheckUser";
        $.get(url, { prodId: id }, function AB(data) {
            if (data == "False") {
                $(".hide").hide();
                $(this).parent().find("a.delete").show();
            }
        });
    }

    function Comment() {
        var id = '@Html.DisplayFor(model => model.ID)';
        $.post("/Product/CommentView", { prodId: id });
    }
   
</script>
<fieldset>
    <legend>Product Detaill</legend>

    <div class="display-label"><img alt="" src='@Model.Image' width="200px" height="200px"/></div>
    <div class="display-label">Name</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Name)
    </div>

    <div class="display-label">Price</div>
    <div class="display-field">
        €@Html.DisplayFor(model => model.Price)
    </div>

    <div class="display-label">Features</div>
    <div class="display-field">
        @Html.TextAreaFor(model => model.Features)
    </div>

    <div class="display-label">StockAvailable</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.StockAvailable)
    </div>

    <div class="display-label">NumberOfRatings</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.NumberOfRatings)
    </div>

    <div class="display-label">AverageRating</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.AverageRating) Over 5(Rated By @Html.DisplayFor(model => model.NumberOfRatings))
    </div>
    <input type="button" onclick="AddToCart()" value="Add To Cart" /> |
    @Html.ActionLink("Rate This Product", "ProductRatings", new { productID= Model.ID }) |
    <label class="hide">@Html.ActionLink("Comment", "Comment", "Product", new { prodId = Model.ID }, null)</label>
</fieldset>

<legend>Comments</legend>

@Html.Action("Comments", "Website", new { ProductID = Model.ID})
